//
//  MineMyTheReleaseViewController.m
//  shuiyun
//
//  Created by 马田成 on 2017/9/6.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "MineMyTheReleaseViewController.h"
#import "ZJScrollPageView.h"
#import "MineMyRelessAnoViewController.h"
#import "MineMyZPViewController.h"
#import "MineMyCYViewController.h"
#import "MineMyMLViewController.h"
@interface MineMyTheReleaseViewController ()<ZJScrollPageViewDelegate>
@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;
@property(strong, nonatomic)NSArray<NSString *> *titles;

@end

@implementation MineMyTheReleaseViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    [self setTitle:@"我的发布"];
    
    // Do any additional setup after loading the view.
}
- (void)creationView{
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    style.scrollTitle = YES;
    style.autoAdjustTitlesWidth = YES;
    style.adjustCoverOrLineWidth = YES;
    style.selectedTitleColor = [UIColor colorWithRed:63 / 255.0f green:135 / 255.0f blue:246 / 255.0f alpha:1];
    style.scrollLineColor = [UIColor colorWithRed:63 / 255.0f green:135 / 255.0f blue:246 / 255.0f alpha:1];
    style.segmentHeight = 40;
    self.titles = @[@"发布招聘",
                    @"发布求职",
                    @"发布船源",
                    @"发布名录",
                    ];
    
    // 初始化
    self.childVcs = [self setupChildVc];
    ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [scrollPageView setSelectedIndex:self.indexID animated:YES];
    scrollPageView.contentView.scrollView.scrollEnabled = YES;
    [self.view addSubview:scrollPageView];
    
    // Do any additional setup after loading the view.
}

#pragma mark ----------------ZJScrollPageViewDelegate---------------------
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}
- (NSArray *)setupChildVc {
    
    MineMyZPViewController *vc1 = [MineMyZPViewController new];
    
    MineMyRelessAnoViewController *vc2 = [MineMyRelessAnoViewController new];
    MineMyCYViewController *vc3 = [MineMyCYViewController new];
    
    MineMyMLViewController *vc4 = [MineMyMLViewController new];
    
    NSArray *childVcs = [NSArray arrayWithObjects:vc1, vc2, vc3, vc4, nil];
    return childVcs;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        childVc = self.childVcs[index];
    }
    
    
    
    
    return childVc;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
